/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pb138.accountingRecords;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/**
 *
 * @author PC
 */
public class TestInvoiceManagerImpl {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws ParseException {

        InvoiceManager invoiceManager = new InvoiceManagerImpl("/db/accounting-records/invoices","admin","admin");

        Invoice invoice = new Invoice();
        invoice.setBankAccount("123456789/1234");
        Subject consumer = new Subject();
        Subject distributor = new Subject();
        consumer.setCity("Brno");
        consumer.setIdNumber(12345678);
        consumer.setMail("consumer@yahoo.com");
        consumer.setStreet("Botanická");
        consumer.setNumber(68);
        consumer.setPostalCode(63500);
        consumer.setPhone("+421905986957");
        consumer.setSubjectName("Masarykova Univerzita");
        invoice.setConsumer(consumer);
        distributor.setCity("Banska Bystrica");
        distributor.setIdNumber(null);
        distributor.setMail("distributor@gmail.com");
        distributor.setNumber(35);
        distributor.setPostalCode(63500);
        distributor.setSubjectName("Jozef Basjel");
        invoice.setDistributor(distributor);
        invoice.setDrawer("Maria Bakoulaova");

        Calendar cal = Calendar.getInstance();
        cal.set(1990,0,11,10,38);

        Calendar from = Calendar.getInstance();
        from.set(1989,7,18,10,37);

        Calendar to = Calendar.getInstance();
        to.set(2012,7,18,10,38);

        invoice.setDueDate(cal.getTime());
        invoice.setInvoiceNumber(1237l);
        invoice.setInvoicingDate(from.getTime());
        List<Item> items = new ArrayList<Item>();
        Item item1 = new Item();
        Item item2 = new Item();
        item1.setCount(5);
        item1.setPriceForUnit(new BigDecimal(20.80));
        item1.setNote("drahe nic");
        item2.setCount(13);
        item2.setPriceForUnit(new BigDecimal(7.80));
        item2.setNote("lacne nic");
        items.add(item1);
        items.add(item2);
        invoice.setItems(items);
        invoice.setPaymentType(PaymentType.TRANSACTION);
        invoice.setVariableSymbol(8545l);
        //invoice.setId("8efa4692.xml");

        //invoiceManager.addInvoice(invoice);

        //invoiceManager.updateInvoice(invoice);
        //System.out.println(invoiceManager.getInvoice("9a06b06a.xml"));
        System.out.println(invoiceManager.getInvoiceAsHTML("129a3320.xml"));
        //invoiceManager.removeInvoice("b9527c81.xml");
        /*List<Invoice> invList = invoiceManager.getInvoicesForPeriod(from.getTime(), to.getTime());
        for(int i = 0; i < invList.size();i++){
            System.out.println(invList.get(i));
        }*/
        //System.out.println(invoiceManager.sumOfInvoicesForPeriod(from.getTime(), to.getTime()).toString());
    }
}
